package com.weijianhuawen.wjblog.admin.convert;

import com.weijianhuawen.wjblog.admin.mode.vo.wiki.FindOneWikiRspVo;
import com.weijianhuawen.wjblog.admin.mode.vo.wiki.FindWikiPageListRspVo;
import com.weijianhuawen.wjblog.common.domain.dos.WikiDo;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;
import org.mapstruct.factory.Mappers;

/**
 * @version: java version 8
 * @Author: weijianhuawen
 * @description:
 * @date: 2024-11-11 15:10
 */
@Mapper
public interface WikiConvert {
    // 初始化转换器实例
    public  WikiConvert INSTANCE = Mappers.getMapper(WikiConvert.class);

    // 将do 转换为 vo 分页
    @Mappings({
            @Mapping(target = "isTop", expression = "java(bean.getWeight() > 0)")
    })
    public FindWikiPageListRspVo convertDo2Vo(WikiDo bean);
    // 将do 转换为 vo 单个
    @Mappings({
            @Mapping(target = "isTop", expression = "java(bean.getWeight() > 0)")
    })
    public FindOneWikiRspVo convertDo2OneVo(WikiDo bean);
}
